<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>

    <!-- Bootstrap -->
    <link href="<?=base_url();?>/public/resource/default/vendor/bootstrap/css/bootstrap.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link href="<?=base_url();?>/public/resource/default/css/style.css" rel="stylesheet" >

</head>
<body>

    <div class="container-fluid wp-content">

        <div class="wp-content-mbx">
            <a><span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span></a>
            <div>
                <span class="mainhead">文章管理</span>
                <span class="subhead">这里是其他的说明性文字</span>
            </div>
        </div>

        <div>

            <!-- 操作提示框 -->
            <div class="alert alert-success" role="alert">
                <a href="#" class="alert-link">...</a>
                Heads up! This alert needs your attention, but it's not super important.
            </div>

            <!-- Nav tabs -->
            <ul class="nav nav-tabs" role="tablist">
                <li role="presentation" <?php if ( !$post_status ) : echo "class='active'"; endif;?> ><a href="<?=site_url(array('post','index'))?>">全部文章</a></li>
                <li role="presentation" <?php if ( $post_status == 'publish' ) : echo "class='active'"; endif;?> ><a href="<?=site_url(array('post','index','?post_status=publish'))?>">已发布</a></li>
                <li role="presentation" <?php if ( $post_status == 'delete' ) : echo "class='active'"; endif;?> ><a href="<?=site_url(array('post','index','?post_status=delete'))?>">回收站</a></li>
            </ul>

            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="home">

                    <div class="wp-panel panel-default">

                        <div class="wp-panel-heading">
                            <span class="wp-h-mainhead">分类列表</span>
                            <span class="wp-h-subhead">共 <strong>111</strong> 条记录</span>
                            <a class="btn btn-sm btn-primary" href="<?=site_url(array('post','post_new'))?>" >写文章</a>
                        </div>

                        <div class="wp-panel-tool">
                            <div class="pull-right">
                                <input type="text" class="dd-form-control" />
                                <button class="btn btn-sm btn-default active">搜索</button>
                            </div>
                            <div>
                                <select class="dd-form-control" name="action">
                                    <option value="">批量操作</option>
                                    <option value="del">删除</option>
                                </select>
                                <button class="btn btn-sm btn-default active" onclick="fun_do_action();">确认</button>
                            </div>

                            <div>
                                <select class="dd-form-control" name="action">
                                    <option value="">2015年十月</option>
                                    <option value="">2015年九月</option>
                                </select>
                                <select class="dd-form-control" name="action">
                                    <option value="">分类1</option>
                                    <option value="">分类2</option>
                                </select>
                                <button class="btn btn-sm btn-default active" onclick="fun_do_action();">筛选</button>
                            </div>
                            <i class="clearfix"></i>
                        </div>

                        <div class="wp-panel-body">
                            <div class="table-responsive">
                                <table class="table table-hover wp-table">
                                    <thead>
                                        <tr>
                                            <th width="40"><input id="checkAll" type="checkbox" value=""></th>
                                            <th width="48%">标题</th>
                                            <th width="10%">作者</th>
                                            <th width="14%">分类目录</th>
                                            <th width="13%">标签</th>
                                            <th width="5%">评论</th>
                                            <th width="10%">发布日期</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <?php if ( !empty($posts) ) : ?>
                                    <?php foreach ($posts as $post) : ?>
                                    <tr>
                                        <td class="td-check"><input name="check" type="checkbox" value="<?=$post->ID?>"></td>
                                        <td>
                                            <strong><?=$post->post_title?></strong>
                                            <br>
                                            <div class="row-action">
                                                <span><a href="<?=site_url(array('post','post_edit','?id=' . hashids_encode($post->ID)))?>">快速编辑</a></span> &Iota;
                                                <span><a class="action-danger" href="javascript:fun_del_post('<?=hashids_encode($post->ID);?>');">删除</a></span> &Iota;
                                                <span><a href="">查看</a></span>
                                            </div>
                                        </td>
                                        <td><?=$post->user_nickname?></td>
                                        <td>
                                            <?php if (!empty($post->categorys)) : ?>
                                            <?php foreach ($post->categorys as $key => $category) :
                                                if (0 !== $key) : echo "、"; endif;
                                            ?>
                                                <a href="#"><?=$category->category_name?></a>
                                            <?php endforeach; ?>
                                            <?php endif; ?>
                                        </td>
                                        <td>
                                            <?php if (!empty($post->tags)) : ?>
                                                <?php foreach ( $post->tags as $key => $tag ) :
                                                    if (0 !== $key) : echo "、"; endif;
                                                ?>
                                                    <a href="#"><?=$tag->tag_name?></a>
                                                <?php endforeach; ?>
                                            <?php endif;?>
                                        </td>
                                        <td><a href=""><span class="badge">20</span></a></td>
                                        <td style="color:#666;"><?=$post->post_date?></td>
                                    </tr>
                                    <?php endforeach; ?>
                                    <?php endif; ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <nav>
                    <?php echo $page ?>
                    </nav>

                </div>

            </div>

        </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="<?=base_url();?>/public/resource/default/vendor/bootstrap/js/bootstrap.min.js"></script>

    <script src="<?=base_url();?>/public/resource/default/js/init.js"></script>

    <script>

        function fun_del_post(id) {
            if (confirm('确认删除该文章吗?'))
            {
                $.post(
                    '<?=site_url(array("post","post_del"));?>',
                    {ids:id},
                    function(response){
                        alert(response.resultMsg);
                        if (response.resultCode == CHttp.getConstant('HTTP_STATUS_SUCCESS'))
                        {
                            location.reload();
                        }
                    },
                    'json'
                );
            }
        }

    </script>
</body>
</html>